package com.itheima.inetaddress;

import java.io.*;
import java.net.Socket;

public class Demo08 {
    public static void main(String[] args) throws IOException {
        //创建客户端
        Socket socket = new Socket("127.0.0.1", 10000);

        //写数据,创建输出流
        OutputStream os = socket.getOutputStream();
        //写数据
        os.write("hello".getBytes());


        //暂停输出流
        socket.shutdownOutput();

        //接收数据
//        InputStream is = socket.getInputStream();
//        int b;
//        while((b = is.read())!= -1){
//            System.out.println((char)b);
//        }

        //进行包装
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

        String line;
        while((line = br.readLine())!=null){
            System.out.println(line);
        }

        socket.close();
        os.close();
        br.close();


    }
}
